page.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { notFound } from 'next/navigation';
  2. import { fetchJson } from '@/lib/utils/server';
  3. import { fetchUserFeed } from '@/lib/api/account/profile';
  4. import { ResultDto } from '@/types/response/common';
  5. import { ChannelDetail } from '@/types/channel';
  6. import FeedList from '@/app/(main)/feed/_component/FeedList';
  7. type Props = {
  8. params: Promise<{ identifier: string }>;
  9. };
  10. export default async function ChannelPostsPage({ params }: Props) {
  11. const { identifier } = await params;
  12. const chRes: ResultDto<ChannelDetail> = await fetchJson(`/api/channel/${encodeURIComponent(decodeURIComponent(identifier))}`, { method: 'GET' });
  13. if (!chRes.data) {
  14. notFound();
  15. }
  16. const memberSID = chRes.data.memberSID;
  17. const feedRes = await fetchUserFeed(memberSID, 1, 20);
  18. const data = feedRes.data ?? { total: 0, list: [], authorSID: memberSID, authorName: chRes.data.name };
  19. return (
  20. <div className="channel-page__tab-content">
  21. <FeedList
  22. initialCards={data.list}
  23. initialTotal={data.total}
  24. endpoint={`/api/member/${encodeURIComponent(memberSID)}/feed`}
  25. emptyMessage="작성한 피드가 없습니다."
  26. />
  27. </div>
  28. );
  29. }